import Vue from "vue";
import VueRouter from "vue-router";

const routes = [
  {
    path: "/login",
    component: () => import("../pages/login.vue"),
  },
  {
    path: "/",
    redirect: () => (localStorage.getItem("isLogin") ? "/home" : "/login"),
    component: () => import("../layout/index.vue"),
    children: [
      {
        path: "/home",
        component: () => import("../pages/home.vue"),
      },
    ],
  },
];

Vue.use(VueRouter);
const router = new VueRouter({
  mode: "history",
  routes,
});
export default router;
